<?php
/**
 * Created by PhpStorm.
 * User: lzy
 * Date: 2018/11/14
 * Time: 17:08
 */
namespace App\FreeBird\Controllers\Home;
use App\Base\Controllers\Controller;
use App\FreeBird\Contracts\ScoreInterface;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;


/**
 * 金币操作
 * Class ScoreController
 * @package App\FreeBird\Controllers\Home
 */
class ScoreController extends Controller
{

    /**
     * 金币操作
     * @return ScoreInterface
     */
    public function getScoreInterface(){
        return app()->make(ScoreInterface::class);
    }
    /**
     * 打开红包
     * @param Request $request
     */
    public function openRedPack(Request $request){
      return $this->getScoreInterface()->openLoginRedPack($request->all());
    }
    /**
     * 打开分享联接
     */
    public function openShareLink(Request $request){
        $validator = Validator::make($request->all(), [
            'uid' => 'required',
        ], ["uid.required" => '推广用户Id']);
        if ($validator->fails()) {
            //$error=$validator->errors()->getMessages();
            $this->throwValidatorException($validator);
        }
        return $this->getScoreInterface()->openShareLink($request->all());
    }
    /**
     * 获取金币列表
     */
    public function getUserScoreList(Request $request){
        $where=function($query){
            $query->where("uid",AUID);
        };
      return $this->getScoreInterface()->getScoreList($where);
    }



}